Telegram Group & Telegram Channel
7. Program to Calculate Area's.

import java.util.Scanner;

class AreaCalculator
{

float l, b, h, r, ba, s, c;
float result = 0f;
float pi = 3.14f;
int var;
public static void main(String[] args)
{
AreaCalculator ar = new AreaCalculator();
ar.options();
}

public void options()
{
Scanner a = new Scanner(System.in);
System.out.println("Enter the Object of which Area is to be calculated \n1:square \n2:rectangle \n3:Triangle\n4:circle\n5:Trapezoid\n6:Repeat\n7:Exit");

var = a.nextInt();
Area a1 = new Area();

if (var == 1)
{
System.out.println("Enter the Side of Square");
s = a.nextFloat();
a1.square(s);
options();
}

else if (var == 2)
{
System.out.println("Enter the Length of Rectangle");
l = a.nextFloat();
System.out.println("Enter the Breadth of Rectangle");
b = a.nextFloat();
a1.rectangle(l, b);
options();
}

else if (var == 3)
{
System.out.println("Enter the Height of Triangle");
h = a.nextFloat();
System.out.println("Enter the Base of Triangle");
ba = a.nextFloat();
a1.triangle(h, ba);
options();
}

else if (var == 4)
{
System.out.println("Enter the Radius of Circle");
r = a.nextFloat();
a1.circle(r);
options();
}

else if (var == 5)
{
System.out.println("Enter the A side of Trapezoid");
b = a.nextFloat();
System.out.println("Enter the B side of Trapezoid");
c = a.nextFloat();
System.out.println("Enter the Height of Trapezoid");
h = a.nextFloat();
a1.trapezoid(b, c, h);
options();
}
}
}

class Area
{
public void square(float s)
{
float result = 0f;
result = s * s;
System.out.println("The Area of Square is :" + result);
}

public void rectangle(float l, float b)
{
float result = 0f;
result = l * b;
System.out.println("The Area of Rectangle is :" + result);
}

public void triangle(float h, float ba)
{
float result = 0f;
result = 0.5f * h * ba;
System.out.println("The Area of Triangle is :" + result);
}

public void circle(float r)
{
float result = 0f;
result = 3.14f * (r * r);
System.out.println("The Area of Circle is :" + result);
}

public void trapezoid(float b, float c, float h)
{
float result = 0f;
result = (((b + c) / 2) * h);
System.out.println("The Area of Trapezoid is :" + result);
}
}

@java_codings



tg-me.com/java_codings/11
Create:
Last Update:

7. Program to Calculate Area's.

import java.util.Scanner;

class AreaCalculator
{

float l, b, h, r, ba, s, c;
float result = 0f;
float pi = 3.14f;
int var;
public static void main(String[] args)
{
AreaCalculator ar = new AreaCalculator();
ar.options();
}

public void options()
{
Scanner a = new Scanner(System.in);
System.out.println("Enter the Object of which Area is to be calculated \n1:square \n2:rectangle \n3:Triangle\n4:circle\n5:Trapezoid\n6:Repeat\n7:Exit");

var = a.nextInt();
Area a1 = new Area();

if (var == 1)
{
System.out.println("Enter the Side of Square");
s = a.nextFloat();
a1.square(s);
options();
}

else if (var == 2)
{
System.out.println("Enter the Length of Rectangle");
l = a.nextFloat();
System.out.println("Enter the Breadth of Rectangle");
b = a.nextFloat();
a1.rectangle(l, b);
options();
}

else if (var == 3)
{
System.out.println("Enter the Height of Triangle");
h = a.nextFloat();
System.out.println("Enter the Base of Triangle");
ba = a.nextFloat();
a1.triangle(h, ba);
options();
}

else if (var == 4)
{
System.out.println("Enter the Radius of Circle");
r = a.nextFloat();
a1.circle(r);
options();
}

else if (var == 5)
{
System.out.println("Enter the A side of Trapezoid");
b = a.nextFloat();
System.out.println("Enter the B side of Trapezoid");
c = a.nextFloat();
System.out.println("Enter the Height of Trapezoid");
h = a.nextFloat();
a1.trapezoid(b, c, h);
options();
}
}
}

class Area
{
public void square(float s)
{
float result = 0f;
result = s * s;
System.out.println("The Area of Square is :" + result);
}

public void rectangle(float l, float b)
{
float result = 0f;
result = l * b;
System.out.println("The Area of Rectangle is :" + result);
}

public void triangle(float h, float ba)
{
float result = 0f;
result = 0.5f * h * ba;
System.out.println("The Area of Triangle is :" + result);
}

public void circle(float r)
{
float result = 0f;
result = 3.14f * (r * r);
System.out.println("The Area of Circle is :" + result);
}

public void trapezoid(float b, float c, float h)
{
float result = 0f;
result = (((b + c) / 2) * h);
System.out.println("The Area of Trapezoid is :" + result);
}
}

@java_codings

BY Advance Java πŸ‘¨β€πŸ’»


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/java_codings/11

View MORE
Open in Telegram


Advance Java ‍ Telegram | DID YOU KNOW?

Date: |

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

Telegram announces Anonymous Admins

The cloud-based messaging platform is also adding Anonymous Group Admins feature. As per Telegram, this feature is being introduced for safer protests. As per the Telegram blog post, users can β€œToggle Remain Anonymous in Admin rights to enable Batman mode. The anonymized admin will be hidden in the list of group members, and their messages in the chat will be signed with the group name, similar to channel posts.”

Advance Java ‍ from br


Telegram Advance Java πŸ‘¨β€πŸ’»
FROM USA